package com.ryskoo.catering.coupon.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.ryskoo.common.constant.CouponConstant;
import com.ryskoo.common.hclconstant.CouponTypeEnum;
import com.ryskoo.framework.core.bean.BasicPO;
import com.ryskoo.framework.core.utils.DateFormatHelper;

/**
 * 优惠券
 *
 * @author BeHappy
 */
@Entity
@Table(name = "cater_coupon")
public class CouponPO extends BasicPO {

    private static final long serialVersionUID = 2462612953304971519L;
    /**
     * 卖家uuid
     */
    @Column(name = "vendor_uuid", columnDefinition = "char", length = 32)
    private String vendorUuid;

    /**
     * 优惠券名称
     */
    @Column(name = "coupon_name", columnDefinition = "varchar", length = 50)
    private String couponName;

    /**
     * 优惠券类型
     */
    @Column(name = "coupon_type", columnDefinition = "tinyint", length = 2)
    private int couponType;
    
    /**
     *  获取方式： 1.前台领取   2.后台发放  
     */
	@Column(name = "obtain_type", columnDefinition = "tinyint", length = 2)
	private int obtainType ;

	/**
	 *  状态： 1.启用  0.停用
	 */
	@Column(name = "state", columnDefinition = "bit", length = 1)
	private boolean state = false ;
	
    /**
     * 面值
     */
    @Column(name = "coupon_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double couponPrice;

    /**
     * 使用条件
     */
    @Column(name = "reach_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double reachPrice;

    /**
     * 有效开始时间
     */
    @Column(name = "start_valid_time", columnDefinition = "char", length = 19)
    private String startValidTime;

    /**
     * 有效结束时间
     */
    @Column(name = "end_valid_time", columnDefinition = "char", length = 19)
    private String endValidTime;

    /**
     * 总计发布数量
     */
    @Column(name = "total_num", columnDefinition = "int")
    private int totalNum;

    /**
     * 已经生成数量
     */
    @Column(name = "generate_num", columnDefinition = "int")
    private int generateNum;

    /**
     * 每人限领数量
     */
    @Column(name = "limit_num", columnDefinition = "int")
    private int limitNum;

    /**
     * 关联商品uuid
     */
    @Column(name = "product_uuid", columnDefinition = "char", length = 32)
    private String productUuid;

    @Transient
    private String productName;

    @Transient
    private String couponTypeName;
    
    /**
     * 用户是否可领取，默认可领取
     */
    @Transient
    private boolean receive = true;
    
    @Transient
	private String obtainTypeName;
    @Transient
	private String couponClientName;
    @Transient
	private int couponState;
    @Transient
	private String couponStateName;
    /**
     * 判断是否过期
     */
    @Transient
    private boolean overdue = false;
    
    
    
    
    public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}
	public boolean isOverdue() {
		if(DateFormatHelper.compareTime(this.endValidTime, DateFormatHelper.getNowTimeStr(), DateFormatHelper.FORMAT_TIME_STR)){
			return true;
		}
		return false;
	}

	public void setOverdue(boolean overdue) {
		this.overdue = overdue;
	}
	public String getVendorUuid() {
        return vendorUuid;
    }

    public void setVendorUuid(String vendorUuid) {
        this.vendorUuid = vendorUuid;
    }

    public String getCouponName() {
        return couponName;
    }

    public void setCouponName(String couponName) {
        this.couponName = couponName;
    }

    public int getCouponType() {
        return couponType;
    }

    public void setCouponType(int couponType) {
        this.couponType = couponType;
    }

    public double getCouponPrice() {
        return couponPrice;
    }

    public void setCouponPrice(double couponPrice) {
        this.couponPrice = couponPrice;
    }

    public double getReachPrice() {
        return reachPrice;
    }

    public void setReachPrice(double reachPrice) {
        this.reachPrice = reachPrice;
    }

    public String getStartValidTime() {
        return startValidTime;
    }

    public void setStartValidTime(String startValidTime) {
        this.startValidTime = startValidTime;
    }

    public String getEndValidTime() {
        return endValidTime;
    }

    public void setEndValidTime(String endValidTime) {
        this.endValidTime = endValidTime;
    }

    public int getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(int totalNum) {
        this.totalNum = totalNum;
    }

    public int getGenerateNum() {
        return generateNum;
    }

    public int getObtainType() {
		return obtainType;
	}

	public void setObtainType(int obtainType) {
		this.obtainType = obtainType;
	}

	public boolean isState() {
		return state;
	}

	public void setState(boolean state) {
		this.state = state;
	}

	public void setGenerateNum(int generateNum) {
        this.generateNum = generateNum;
    }

    public int getLimitNum() {
        return limitNum;
    }

    public void setLimitNum(int limitNum) {
        this.limitNum = limitNum;
    }

    public String getProductUuid() {
        return productUuid;
    }

    public void setProductUuid(String productUuid) {
        this.productUuid = productUuid;
    }

    public String getCouponTypeName() {
		return CouponTypeEnum.getNameByValue(this.couponType);
	}

	public void setCouponTypeName(String couponTypeName) {
		this.couponTypeName = couponTypeName;
	}

	public String getObtainTypeName() {
		return CouponConstant.ObtainTypeEnum.getNameByValue(this.obtainType);
	}

	public void setObtainTypeName(String obtainTypeName) {
		this.obtainTypeName = obtainTypeName;
	}

	public String getCouponClientName() {
		return couponClientName;
	}

	public void setCouponClientName(String couponClientName) {
		this.couponClientName = couponClientName;
	}

	public int getCouponState() {
		return couponState;
	}

	public void setCouponState(int couponState) {
		this.couponState = couponState;
	}

	public String getCouponStateName() {
		return couponStateName;
	}

	public void setCouponStateName(String couponStateName) {
		this.couponStateName = couponStateName;
	}

    public boolean isReceive() {
        return receive;
    }

    public void setReceive(boolean receive) {
        this.receive = receive;
    }

}
